<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>


    url = "/WebPageServer/login";

    var xmlhttp;


    if (window.XMLHttpRequest) {

        //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码

        xmlhttp = new XMLHttpRequest();

    } else {

        // IE6, IE5 浏览器执行代码

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

    }


    xmlhttp.onreadystatechange = function () {

        onResponse();

    }


    // POST提交数据

    xmlhttp.open("POST", url, true);


    xmlhttp.setRequestHeader('content-type', 'application/x-www-form-urlencoded');

    xmlhttp.send("userName=123");


    function onResponse() {

        var res = null;

        if (xmlhttp.readyState == 4) { // XMLHttpRequest的就绪状态码，对象读取响应结束

            if (xmlhttp.status == 200) { // http的状态码，服务器响应正常

                res = xmlhttp.responseText;

            } else {


            }

        }

        //转成JSON对象

        var jsonObj = JSON.parse(res);


    }

</script>


</body>
</html>